﻿import java.util.Scanner;
class Factorial extends Thread{
    private long result = 1;
    private int n = 0;
    public Factorial(int n){
        this.n = n;
    }
    public long getResult(){
        return result;
    }
    public int getN(){
        return n;
    }
    public void run(){
        for(int i = 1; i<=n; i++){
            result *= i;
            try{
                sleep((int)(Math.random()*1000));
            } catch (InterruptedException e){};
        }
    }
}

public class exp1{
    public static void main (String args[]){
        Scanner Input = new Scanner(System.in);
        System.out.print("输入m：");
        int m = Input.nextInt();
        System.out.print("输入n：");
        int n = Input.nextInt();
        Factorial t1 = new Factorial(m);
        Factorial t3 = new Factorial(m-n);
        t1.start();

        t3.start();

        try {
            t1.join();
            t3.join();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.print("组合数P("+m+","+n+")=");
        System.out.println(t1.getResult()/t3.getResult());
    }
}

